FROM golang:1.24.2 AS builder

ENV GOPROXY=https://goproxy.cn,direct

WORKDIR /app
COPY go.mod go.sum ./
RUN go mod download

COPY . ./  
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 \
    go build -o /backend .

# ---- 运行阶段 ----
FROM debian:bookworm-slim

# 安装最小化 shell 工具，便于调试和查看文件结构
RUN apt-get update && apt-get install -y --no-install-recommends \
    bash \
    coreutils \
  && rm -rf /var/lib/apt/lists/*

WORKDIR /app
COPY --from=builder /backend .
COPY --from=builder /app/config.yaml .


EXPOSE 9996
ENTRYPOINT ["/app/backend"]
